package com.joelaws.blackberry;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.LabelField;

public class ViewMeetingsScreen extends BaseScreen {
	public ViewMeetingsScreen(final String userID, String[] users,
			Bitmap[] images) {
		if (users.length == 0) {
			add(new LabelField("No Meetings"));
			return;
		}

		for (int i = 0; i < users.length; i++) {

			final String otherUserID = users[i];

			final Bitmap image = images[i];
			add(new BitmapField(image));

			ButtonField browse = new ButtonField("View Meeting");

			browse.setChangeListener(new FieldChangeListener() {
				public void fieldChanged(Field field, int context) {
					new Thread() {
						public void run() {
							pushScreen(new MeetScreen(userID, otherUserID));
						}
					}.start();
				}
			});

			add(browse);

			add(new LabelField(""));
		}

	}
}
